const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
// const TestPlugin = require("./MyPlugin/test-plugin");
// const BannerWebpackPlugin = require("./MyPlugin/banner-webpack-plugin");
const CleanWebpackPlugin = require("./MyPlugin/clean-webpack-plugin");
const AnalyzeWebpackPlugin = require("./MyPlugin/analyze-webpack-plugin");

module.exports = {
 entry: './src/main.js',
 output: {
  path: path.resolve(__dirname,'./dist'),
  filename: 'js/[name].js',
  assetModuleFilename:'static/image/[hash:8][ext][query]',
  // clean: true,
 },
 module:{
  rules:[
    // {
    //   test: /\.js$/,
    //   loader: "./loaders/test-loader.js",
    // }
    {
      test: /\.js$/,
      use:[
        // "./loaders/demo/test1","./loaders/demo/test2"
        // "./loaders/demo/test3"
        "./loaders/clean-log-loader.js",
        
      ],
    },
    // {
    //   test: /\.js$/,
    //   loader: "./loaders/banner-loader",
    //   options:{
    //     author: "cans",
    //   }
    // },
    {
      test: /\.js$/,
      loader: "./loaders/babel-loader",
      options:{
        presets: ["@babel/preset-env"],
      }
    },
    // {
    //   test: /\.(png|jpe?g|gif)$/,
    //   loader: "./loaders/file-loader",
    //   type: 'javascript/auto', // 阻止webpack默认处理图片资源，只使用file-loader 处理
    // },
    // {
    //   test:/\.css$/,
    //   use:["style-loader","css-loader"]
    // },
    {
      test:/\.css$/,
      use:["./loaders/style-loader","css-loader"]
    },
  ]
 },
 plugins: [
  new HtmlWebpackPlugin({
    template: path.resolve(__dirname, 'public/index.html'),
  }),
  // new TestPlugin(),
  // new BannerWebpackPlugin({
  //   author:"cans"
  // }),
  new CleanWebpackPlugin(),
  new AnalyzeWebpackPlugin(),
 ],
 mode: "production"
}